package org.example.erp.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.example.erp.domain.Material;
import org.example.erp.domain.SysDept;
import org.example.erp.myInterface.NodeMapper;
import org.example.erp.service.SysDeptService;
import org.example.erp.mapper.SysDeptMapper;
import org.example.erp.utils.TreeBuild;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author Administrator
* @description 针对表【sys_dept(部门管理表)】的数据库操作Service实现
* @createDate 2024-11-03 18:41:19
*/
@Service
public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept>
    implements SysDeptService{
    public List<SysDept> findDeptList(String deptName, Integer status){
        List<SysDept> deptList = baseMapper.findDeptList(deptName,status);
        TreeBuild<SysDept> treeBuild = new TreeBuild<>();
        // 创建NodeMapper实例
        NodeMapper<SysDept> sysDeptNodeMapper = TreeBuild.createNodeMapper(
                SysDept::getDeptId,
                SysDept::getParentId,
                SysDept::getChildren,
                SysDept::setChildren
        );
        return  treeBuild.buildTree(deptList,sysDeptNodeMapper);
    }

}




